package _15_lianxi;

import java.util.LinkedList;

public class Dog {

	public static void main(String[] args) {
		LinkedList<Dog1> l1 = new LinkedList<Dog1>();
		Dog1 d1 = new Dog1(10001, "ww");
		Dog1 d2 = new Dog1(10002, "qq");
		Dog1 d3 = new Dog1(10003, "aa");
		Dog1 d4 = new Dog1(10004, "ss");
		Dog1 d5 = new Dog1(10005, "dd");
		l1.add(d1);
		l1.add(d2);
		l1.add(d3);
		l1.add(d4);
		l1.add(d5);
		System.out.println("集合的长度为 : " + l1.size());
		System.out.println(l1.contains(new Dog1(10004, "ss")));
	}

}

class Dog1 {
	int id;
	String name;

	public Dog1(int id, String name) {
		super();
		this.id = id;
		this.name = name;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (obj instanceof Dog1) {
			Dog1 d = (Dog1) obj;
			if (d.id == this.id && d.name.equals(this.name)) {
				return true;
			}
		}
		return false;
	}

	@Override
	public String toString() {
		return "Dog1 [id=" + id + ", name=" + name + "]";
	}

}